package com.lxmes.hr.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.lxmes.common.annotation.Log;
import com.lxmes.common.core.controller.BaseController;
import com.lxmes.common.core.domain.AjaxResult;
import com.lxmes.common.enums.BusinessType;
import com.lxmes.hr.domain.NcEleAttend;
import com.lxmes.hr.service.INcEleAttendService;
import com.lxmes.common.utils.poi.ExcelUtil;
import com.lxmes.common.core.page.TableDataInfo;

/**
 * 电子考勤Controller
 * 
 * @author ruoyi
 * @date 2022-11-25
 */
@RestController
@RequestMapping("/hr/eleAttend")
public class NcEleAttendController extends BaseController
{
    @Autowired
    private INcEleAttendService ncEleAttendService;

    /**
     * 查询电子考勤列表
     */
    @PreAuthorize("@ss.hasPermi('hr:eleAttend:list')")
    @GetMapping("/list")
    public TableDataInfo list(NcEleAttend ncEleAttend)
    {
        startPage();
        List<NcEleAttend> list = ncEleAttendService.selectNcEleAttendList(ncEleAttend);
        return getDataTable(list);
    }

    /**
     * 导出电子考勤列表
     */
    @PreAuthorize("@ss.hasPermi('hr:eleAttend:export')")
    @Log(title = "电子考勤", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, NcEleAttend ncEleAttend)
    {
        List<NcEleAttend> list = ncEleAttendService.selectNcEleAttendList(ncEleAttend);
        ExcelUtil<NcEleAttend> util = new ExcelUtil<NcEleAttend>(NcEleAttend.class);
        util.exportExcel(response, list, "电子考勤数据");
    }

    /**
     * 获取电子考勤详细信息
     */
    @PreAuthorize("@ss.hasPermi('hr:eleAttend:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(ncEleAttendService.selectNcEleAttendById(id));
    }

    /**
     * 新增电子考勤
     */
    @PreAuthorize("@ss.hasPermi('hr:eleAttend:add')")
    @Log(title = "电子考勤", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody NcEleAttend ncEleAttend)
    {
        return toAjax(ncEleAttendService.insertNcEleAttend(ncEleAttend));
    }

    /**
     * 修改电子考勤
     */
    @PreAuthorize("@ss.hasPermi('hr:eleAttend:edit')")
    @Log(title = "电子考勤", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody NcEleAttend ncEleAttend)
    {
        return toAjax(ncEleAttendService.updateNcEleAttend(ncEleAttend));
    }

    /**
     * 删除电子考勤
     */
    @PreAuthorize("@ss.hasPermi('hr:eleAttend:remove')")
    @Log(title = "电子考勤", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(ncEleAttendService.deleteNcEleAttendByIds(ids));
    }
}
